﻿using System;
using System.Collections.Generic;
using System.Text;

namespace _01单例模式
{
    //在方法里new  ,这里使用 双if-lock
    public  class SingleFirst
    {
        private static SingleFirst _SingleFirst;
        private static readonly object _Single_Lock = new object();
        private SingleFirst() { }
        public static SingleFirst GetInstance()
        {
            if(_SingleFirst == null)
            {
                lock (_Single_Lock)
                {
                    if(_SingleFirst == null)
                    {
                        _SingleFirst = new SingleFirst();
                    }
                }
            }
            return _SingleFirst;
        }
        
    }
}
